home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 4 / QRZ Ham Radio Callsign Database - Volume 4.iso / files / amiga / nosutils.lha / SendMail.rx < prev   
Text File  |  1993-12-05  |  3KB  |  134 lines

  1. /* SendMail version 19931205 */
  2. /* AREXX program to convert AmigaELM mail to AmigaNOS smtp compatible */
  3.  
  4. /* Edit the following two lines for your system */
  5. /************************************************/
  6.  
  7. mailhost='n2mfc.ampr.org'        /* name of mail host */
  8. stationcall='n2mfc'                /* station call sign */
  9.  
  10. /************************************************/
  11.  
  12.  
  13. if ~show('L',"rexxsupport.library") then do
  14.     call addlib('rexxsupport.library',0,-30,0)
  15. end
  16.  
  17. signal on BREAK_C
  18.  
  19. tz='GMT'
  20. if open(timezone,'ENV:TZ','R') then do
  21.     tz=left(readln(timezone),3)
  22.     close(timezone)
  23. end
  24.  
  25. ccflag=0
  26. bccflag=0
  27.  
  28. open(mailout,'T:sendmail.tmp','W')
  29.  
  30. writeln(mailout,'Date: '||left(date('W'),3)||', '||date()||' '||time()||' '||tz)
  31. hdrchk=1
  32. do while ~eof(STDIN)
  33.     line=readln(STDIN)
  34.     if hdrchk then do
  35.         if upper(left(line,5))=='FROM ' then iterate
  36.         if upper(left(line,6))=='FROM: ' then do
  37.             if index(line,".txt")>0 then line=left(line,index(line,".txt")-1)||right(line,length(line)-index(line,".txt")-3)
  38.         end
  39.         if upper(left(line,9))=='SUBJECT: ' then hdrchk=0
  40.         if upper(left(line,4))=='CC: ' then do
  41.             parse var line cc cc.1 cc.2 cc.3 cc.4 cc.5 cc.6 cc.7 cc.8 cc.9 cc.10 .
  42.             if length(cc.1)>0 then ccflag=1
  43.         end
  44.         if upper(left(line,5))=='BCC: ' then do
  45.             parse var line bcc bcc.1 bcc.2 bcc.3 bcc.4 bcc.5 bcc.6 bcc.7 bcc.8 bcc.9 bcc.10 .
  46.             if length(bcc.1)>0 then bccflag=1
  47.         end
  48.     end
  49.     writeln(mailout,line)
  50. end
  51. close(mailout)
  52.  
  53. ccprocessing=0
  54. bccprocessing=0
  55. call Process
  56. if ccflag then do
  57.     ccprocessing=1
  58.     do i=1 to 10 for 10
  59.         if length(cc.i)<1 then leave i
  60.         call open(mailin,file,'R')
  61.         call Process
  62.     end
  63.     ccprocessing=0
  64. end
  65.  
  66. if bccflag then do
  67.     bccprocessing=1
  68.     do i=1 to 10 for 10
  69.         if length(bcc.i)<1 then leave i
  70.         call open(mailin,file,'R')
  71.         call Process
  72.     end
  73.     bccprocessing=0
  74. end
  75.  
  76. call delete('T:sendmail.tmp')
  77. exit 0
  78.  
  79. Process:
  80.     if ~open(seqfile,'TCPIP:spool/mqueue/sequence.seq','R') then do
  81.         say "***Can't open sequence.seq file, aborting!"
  82.         exit 20
  83.     end
  84.     
  85.     seq=readln(seqfile)
  86.     seq=seq+1
  87.     close(seqfile)
  88.     open(seqfile,'TCPIP:spool/mqueue/sequence.seq','W')
  89.     writech(seqfile,seq)
  90.     close(seqfile)
  91.     
  92.     open(mailout,'TCPIP:spool/mqueue/'||seq||'.txt','W')
  93.     open(mailwrk,'TCPIP:spool/mqueue/'||seq||'.wrk','W')
  94.     writeln(mailwrk,mailhost)
  95.     open(mailin,'T:sendmail.tmp','R')
  96.     
  97.     hdrchk=1
  98.     do while ~eof(mailin)
  99.         line=readln(mailin)
  100.         if hdrchk then do
  101.             if upper(left(line,6))=='FROM: ' then do
  102.                 writeln(mailwrk,substr(line,7,index(line," ",7)-7))
  103.                 writeln(mailout,'Message-Id: <'||seq||'@'||stationcall||'.ampr.org>')
  104.                 writech(stdout,"MsgId "||seq||": "||line||" ")
  105.             end
  106.             if upper(left(line,4))=='TO: ' then do
  107.                 select
  108.                 when ccprocessing then do
  109.                     writeln(mailwrk,cc.i)
  110.                     say 'Cc: '||cc.i
  111.                 end
  112.                 when bccprocessing then do
  113.                     writeln(mailwrk,bcc.i)
  114.                     say 'Bcc: '||bcc.i
  115.                 end
  116.                 otherwise
  117.                     writeln(mailwrk,right(line,length(line)-4))
  118.                     say line
  119.                 end
  120.                 close(mailwrk)
  121.             end
  122.             if upper(left(line,9))=='SUBJECT: ' then hdrchk=0
  123.             if upper(left(line,5))=='BCC: ' then iterate
  124.         end
  125.         writeln(mailout,line)
  126.     end
  127.     close(mailout)
  128.     close(mailin)
  129. return
  130.  
  131. BREAK_C:
  132.     say "*** User break"
  133. exit 10
  134.